package com.transport.action;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.transport.model.Member;
import com.transport.service.MemberService;
import com.transport.utils.BaseAction;

public class MemberAction extends BaseAction {
	private MemberService memberService;
	private Member member;

	public MemberService getMemberService() {
		return memberService;
	}

	public void setMemberService(MemberService memberService) {
		this.memberService = memberService;
	}

	public Member getMember() {
		return member;
	}

	public void setMember(Member member) {
		this.member = member;
	}
	
	public String memberLogin(){
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setContentType("application/json;charset=utf-8");
		Map<String,String> map = new HashMap<String, String>();
		Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
		String flag = memberService.memberLogin(member);
		map.put("status",flag);
		String data = gson.toJson(map);
		System.out.println(data);
		try {
			response.setCharacterEncoding("utf-8");
			response.getWriter().write(data);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	
}
